<link rel="stylesheet" href="css/index.css"/>
<script src="js/jquery-3.4.1.js"></script>
<script src="js/vue.js"></script>
<script src="js/axios.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="js/menu.js"></script>

<div id="app" style="height: 100%;">
    <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">位置</el-breadcrumb-item>
        <el-breadcrumb-item>月度报表</el-breadcrumb-item>
        <el-breadcrumb-item>月度采购报表</el-breadcrumb-item>
    </el-breadcrumb>
    <br/>
    <el-form :inline="true" :model="form" class="demo-form-inline">
        <el-form-item label="日期:">
            <div class="block">
                <el-date-picker
                        v-model="form.date"
                        type="month"
                        placeholder="选择月"
                        value-format="yyyy-MM"
                >
                </el-date-picker>
            </div>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" size="middle" @click="onsubmit">查询</el-button>
        </el-form-item>
    </el-form>
<!--    <el-table :data="tableDataCount" height="50px" border style="width: 100%" key="one">-->
<!--        <el-table-column prop="poMainCount" label="采购单数" width="180"></el-table-column>-->
<!--        <el-table-column prop="endCount" label="已了结单数" width="180"></el-table-column>-->
<!--        <el-table-column prop="poTotalPrice" label="采购总金额" width="180"></el-table-column>-->
<!--        <el-table-column prop="payPrice" label="已付款金额" width="180"></el-table-column>-->
<!--    </el-table>-->
    <div>
        <el-table :data="tableDataCount" height="100px" border style="width: 100%" >
            <el-table-column prop="poMainCount" label="采购单数" width="180"></el-table-column>
            <el-table-column prop="endCount" label="已了结单数" width="180"></el-table-column>
            <el-table-column prop="poTotalPrice" label="采购总金额" width="180"></el-table-column>
            <el-table-column prop="payPrice" label="已付款金额" width="180"></el-table-column>
        </el-table>
    </div>
    <div>
        <el-table :data="tableDataDetails" height="300px" border style="width: 100%" key="two">
            <el-table-column prop="poId" label="采购单编号" width="120"></el-table-column>
            <el-table-column prop="venderCode" label="供应商编号" width="150"></el-table-column>
            <el-table-column prop="venderName" label="供应商名称" width="150"></el-table-column>
            <el-table-column prop="createTime" label="采购日期" width="150"></el-table-column>
            <el-table-column prop="scmuserName" label="经手人" width="150"></el-table-column>
            <el-table-column prop="poTotal" label="采购单总价格" width="150"></el-table-column>
            <el-table-column prop="unPay" label="未付款金额" width="150"></el-table-column>
            <el-table-column prop="status" label="处理状态" width="150">
                <template slot-scope="scope">
                    <span v-if="scope.row.status==1">新建</span>
                    <span v-else-if="scope.row.status==2">收货</span>
                    <span v-else-if="scope.row.status==3">付款</span>
                    <span v-else-if="scope.row.status==4">了结</span>
                    <span v-else-if="scope.row.status==5">预付</span>
                </template>
            </el-table-column>
        </el-table>
    </div>
    <el-pagination
            background
            layout="sizes, prev, pager, next, jumper, ->, total, slot"
            :total="totalRecord"
            :current-page="currentPage"
            :page-size="pageSize"
            :page-sizes="[6,10,15,20]"
            @current-change="handleCurrentChange"
            @size-change="handleSize">
    </el-pagination>
</div>

<script>
    window.onload = function () {

        let vm = new Vue({
            el: "#app",
            data: {
                labelPosition: "left",
                dialogFormVisible: false,
                tableDataCount: [],
                tableDataDetails: [],
                options: [],
                totalRecord: 0,
                currentPage: 1,
                pageSize: 6,
                form: {
                    date: ""
                }
            },
            methods: {
                init: function () {
                    this.onsubmit(this.currentPage, this.pageSize);
                },
                handleCurrentChange: function (val) {
                    this.currentPage = val;
                    this.onsubmit(this.currentPage, this.pageSize);
                },
                handleSize: function (val) {
                    this.pageSize = val;
                    this.currentPage = 1;
                    this.onsubmit(this.currentPage, this.pageSize);
                },
                onsubmit: function (cup, pSize) {
                    let that = this;
                    console.log(this.form.date)
                    if(this.form.date == null){
                        this.form.date = "";
                    }
                    axios.get("queryPoReport?currentPage=" + this.currentPage + "&pageSize=" + this.pageSize + "&date=" + this.form.date).then(function (resp) {
                        // console.log(resp.data.data.lists)
                        that.tableDataDetails = resp.data.data.lists;
                        that.totalRecord = resp.data.data.totalRecord;
                    });
                    //查询采购单各种总数
                    axios.get("queryPoAllCount?date="+this.form.date).then(function (resp){
                        console.log(resp.data);
                        that.tableDataCount = resp.data;
                    });

                    //查询供应商信息
                    // axios.get("getCustomerMassage").then(function (resp){
                    //     that.customersForm.customers = resp.data.data;
                    // });
                },
            }
        });

        vm.init();
    }
</script>